package day18;

public class Climb {
    public void print1() throws InterruptedException {
        String name=Thread.currentThread().getName();
        int hight=1000;
        for (int i=100;i<=hight;i+=100){
            Thread.sleep(500);
            System.out.println(name+"爬完了"+i+"米！");
            if (i==1000){
                System.out.println(name+"先爬到了山顶!");
                System.exit(0);
            }
        }
    }
    public void print2() throws InterruptedException {
        String name=Thread.currentThread().getName();
        int hight=1000;
        for (int i=100;i<=hight;i+=100){
            Thread.sleep(1000);
            System.out.println(name+"爬完了"+i+"米！");
            if (i==1000){
                System.out.println(name+"先爬到了山顶!");
                System.exit(0);
            }
        }
    }

    public static void main(String[] args) {
         Climb c=new Climb();
        new Thread(()->{
            try {
                c.print1();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"张三").start();

        new Thread(()->{
            try {
                c.print2();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        },"李四").start();
    }
}
